home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / Magic 8-Ball / MEB.h < prev    next >
Encoding:
Text File  |  1999-01-01  |  4.4 KB  |  170 lines  |  [TEXT/MPS ]

  1. //******************************************************************************
  2. //******************************************************************************
  3. /*
  4.     File:        Brickout.h
  5.  
  6.     Contains:    Header for a sample dcmd which plays brickout.
  7.  
  8.     Written by:    Andy Bachorski and Nat McCully
  9.  
  10.     Copyright:    © 1998 by Apple Computer, Inc., All Rights Reserved.
  11.  
  12.     Change History (most recent first):
  13.     
  14.         <1> 98-6-19        Written for the MacHack 98 Hack Contest.
  15.  
  16.     The following MPW commands will build the dcmd and copy it to the "Debugger Prefs" file
  17.     in the System folder. The dcmd's name in MacsBug will be the name of the file built by
  18.     the Linker.
  19.  
  20.     set MacsBugLibs "Tools:OtherSDKs:Building dcmds:MacsBug 6.5.4a3:MacsBug 6.5.4a3:Building dcmds:dcmd Libraries:"
  21.     SC BrickOut.c  -i "Tools:OtherSDKs:Building dcmds:MacsBug 6.5.4a3:MacsBug 6.5.4a3:Building dcmds:dcmd Includes:"
  22.     Link -o BrickOut -sg Main=STDCLIB,STDIO,SANELIB BrickOut.o ∂                                                                ∂
  23.         "{MacsBugLibs}dcmdGlue.a.o"
  24.     BuildDcmd BrickOut 195 -format3
  25.     Echo 'include "BrickOut";'    |    Rez -a -o "{SystemFolder}Debugger Prefs"
  26.  
  27. */
  28.  
  29.  
  30. //******************************************************************************
  31.  
  32. #ifndef _MacBrickOut_
  33. #define _MacBrickOut_
  34.  
  35. #include <Memory.h>
  36. #include <Quickdraw.h>
  37. #include <Types.h>
  38.  
  39. //#include <string.h>
  40.  
  41. #include "dcmd.h"
  42.  
  43. //******************************************************************************
  44.  
  45. #define    MaxSpeed        4
  46.  
  47. #define    BricksH            numBricksX
  48. #define    BricksV            numBricksY
  49.  
  50. #define    WidthCalc        brickWidth
  51. #define    HeightCalc        brickHeight
  52.  
  53. #define kHit            1
  54. #define    kSafe            0
  55.  
  56. #define    KeyMapLoMem     ((unsigned char *)0x174)
  57. #define KeyIsDown(key)    (( KeyMapLoMem[ key >> 3 ] >> ( key & 7)) &1)
  58.  
  59. #define    aKey            0x00
  60. #define    sKey            0x01
  61. #define qKey            0x0C
  62. #define    fourKey            0x56
  63. #define    sixKey            0x58
  64.  
  65. #define kSplashColorBlack    0x15
  66. #define kSplashColorBlue    0x02
  67. #define kSplashColorLtBlue    0x03
  68. #define kSplashColorGreen    0x04
  69. #define kSplashColorPurple    0x01
  70. #define kSplashColorRed        0x06
  71. #define kSplashColorYellow    0x05
  72.  
  73. //******************************************************************************
  74.  
  75. enum {
  76.     kScreenLines    = 42,            //    Number of lines to scroll to clear MacsBug screen
  77.     numRows            = 0x01a8,
  78.     topBorder        = 8,
  79.     bottomBorder    = 8,
  80.     sideBorder        = 4,
  81.     leftEdge        = 74,
  82.     brickWidth        = 56,                // byte * 8 = 48 pixels
  83.     halfBrickWidth    = brickWidth / 2,
  84.     brickHeight        = 12,                // 1 row = 1 pixel * 12 = 12 pixels
  85.     halfBrickHeight    = brickHeight / 2,
  86.     numBricksX        = 10,
  87.     numBricksY        = 6,
  88.     kWhite            = 0x00,
  89.     kBlack            = 0x01,
  90.     kRed            = 0x02,
  91.     ballSize        = brickHeight,
  92.     halfBallSize    = ballSize / 2,
  93.     paddleWidth        = brickWidth,
  94.     halfPaddleWidth    = paddleWidth / 2,
  95.     paddleHeight    = brickHeight,
  96.     halfPaddleHeight= brickHeight / 2,
  97.     paddleMoveAmt    = 2
  98. };
  99.  
  100. //******************************************************************************
  101.  
  102. long            gRunning;
  103. long            gFellOff;
  104.  
  105. UInt32        gScreenBase;
  106. UInt32        gVideoRowBytes;
  107. UInt32        gScreenBaseOffset;
  108.  
  109. UInt16        gScreenRowBytes;
  110. UInt32        gDrawBoundsTop;
  111. UInt32        gDrawWidth;
  112.  
  113. UInt16        gBrickLeft;
  114. UInt16        gBrickRight;
  115.  
  116. UInt16        gBallStartX;
  117. UInt16        gBallStartY;
  118.  
  119. Rect        ballRect;
  120. Rect        oldBallRect;
  121.  
  122. UInt16        gPaddleStartX;
  123. UInt16        gPaddleStartY;
  124.  
  125. Rect        paddleRect;
  126. Rect        oldPaddleRect;
  127.  
  128. Point        speed;
  129.  
  130.  
  131. char         blackBall[];
  132. char         whiteBall[];
  133.  
  134. short        BrickState[BricksH][BricksV];
  135. Rect        Bricks[BricksH][BricksV];
  136.  
  137. Point        gSplashDimensions;
  138. Rect        gSplashRect;
  139. char        gSplashBits[];
  140.  
  141. //******************************************************************************
  142.  
  143. pascal    void CommandEntry( dcmdBlock* paramPtr );
  144.  
  145. void    ScrollDisplayOff( void );        //    Scroll the current contents of the Macs
  146.  
  147. void    DoBrickOut( void );                //    The 'event loop' for the game
  148.  
  149. void    PauseWithPolling( void );        //     A way to throttle the speed of the game
  150. void    PauseAndUpdatePaddle( long ticksToWait );
  151. Boolean InitGlobals( void );
  152. long    RowOffset( long y );
  153. void    NumberToHex( UInt32 number, Str255 hex );
  154. void    InitBallStart( void );
  155. void    DrawBorder( void );
  156. void    DrawBricks( void );
  157. void    DrawBrick( short xLoc, short yLoc, Rect *rect );
  158. void    FadeToBlack( void );
  159. void    CheckCollide( void );
  160. char *    XYtoAddress( long xLoc, long yLoc );
  161. void    DrawBall( Rect *ballRectPtr, char * ballBits );
  162. void    UpdateBall( void );
  163. void    DrawPaddle( Rect *paddleRectPtr );
  164. void    UpdatePaddles( void );
  165. void    DrawSplashScreen( Rect *splashRectPtr, char * splashBits, Point * dimensions );
  166.  
  167.  
  168. //******************************************************************************
  169. #endif // _MacBrickOut_
  170.